package com.happyfamily.springboot.crowdsourcingplatform.service.sun.impl;

import com.happyfamily.springboot.crowdsourcingplatform.dao.sun.NedDao;
import com.happyfamily.springboot.crowdsourcingplatform.model.Need;
import com.happyfamily.springboot.crowdsourcingplatform.service.sun.NeedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class NeedServiceImpl implements NeedService
{
	@Autowired(required = false)
	private NedDao needDao;

	@Override
	public List<Need> getList(Integer start, Integer end, String acc, String sname)
	{
		if(sname!=null && sname.equals("所有"))
		{
			sname=null;
		}
		return needDao.getList(start,start*(end-1),acc,sname);
	}

	@Override
	public int getSum(String acc,String sname)
	{
		if(sname!=null && sname.equals("所有"))
		{
			sname=null;
		}
		return needDao.getSum(acc,sname);
	}

	@Override
	public Need getNeed(Long nid)
	{
		return needDao.getNeed(nid);
	}

}